<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
/*
常见的高阶函数:  setTimeout, setInterval

map:

reduce:

 */
var arr = [1, 2, 3, 4, 50];   // [1, 2, 9, 16, 25]

var value = arr.reduce(function (a, ele, index, array){
    return a * ele
}, 1)
console.log(value);

// 求 10!
var arr1 = new Array(7);
arr1.fill(0)
var v1 = arr1.reduce(function (r, ele, index){
    return r * (index + 1);
}, 1)
console.log(v1);
/*var a1 = arr.map(function (x, index, array){
    return x-2;
})
console.log(a1);

console.log(arr.map(Math.sqrt));*/

</script>
</body>
</html>